package com.example.performance.jmh.annotation;

import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import org.openjdk.jmh.runner.options.TimeValue;

import java.util.concurrent.TimeUnit;

/**
 * @author zpMeng
 * @since 9/18/2024
 */
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.MILLISECONDS, batchSize = 1)
public class A2WarmUp {

    @Benchmark
    public double getInt() {
        return 1D;
    }

    public static void main(String[] args) throws RunnerException {
        Options options = new OptionsBuilder().include(A2WarmUp.class.getSimpleName())
                .forks(1)
                .measurementIterations(3)
                .measurementTime(TimeValue.seconds(1) )
                .build();
        new Runner(options).run();
    }
}
